import {api} from './libs/api.js';
let _self;
export const index =  {
	data() {
		return {
			optLock:false,
			dataList:[],
			status:api.status,
			tabSubItem:1,
			icons:[
				{type:"search",size:uni.upx2px(30)},
			],
		}
	},
	
	mounted() {
		_self = this;
	},
	onReachBottom:function(e){
		this.params.page+=1;
		this.initData();
	},
	onLoad:function(option) {
		this.tabSubItem=option.status;
	},
	
	methods: {
		async initData(){
			uni.showLoading({title: '加载中'});
			this.params["status"]=this.tabSubItem;
			let orderInfo=await api.dataList(this.params);
			if(this.params.page==1){
				this.dataList=orderInfo["dataList"];
			}else{
				if(orderInfo["dataList"].length==0) this.params.page-=1;
				this.dataList.push.apply(this.dataList,orderInfo["dataList"]);
			}
			uni.hideLoading();
		},
		
		selectTab:function(event){
			this.params.page=1;
			this.tabSubItem=event.currentTarget.dataset.id;
			this.initData();
		},
		
		seachInfo(){this.initData();},
		
		
		async deliverConfirm(id){
			let retInfo=await api.confirmDeliver({"id":id});
			if(retInfo=="true"){
				uni.showToast({icon:"none",title:"提交成功！"});
				setTimeout(function(){_self.initData();},2000);　　
			}
		}
		
				
	},
}